/**
 * 页面中复用的钩子与逻辑
 */

import { findBanner } from '@/api/home.js'
import { ref, onMounted } from 'vue'

export function useBanner () {
  // 定义轮播图数组
  const bannerList = ref([])
  // async function getBannerList () {
  //   const res = await findBanner()
  //   console.log('轮播图', res)
  //   bannerList.value = res.result
  // }
  const getBannerList = async () => {
    const res = await findBanner()
    console.log('轮播图', res)
    bannerList.value = res.result
  }
  onMounted(() => {
    getBannerList()
  })
  return { bannerList }
}
